home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_483 / inputlock / inputlock.asm < prev    next >
Assembly Source File  |  1992-05-06  |  18KB  |  681 lines

  1. *    InputLock V1.0
  2. *    By Preben Nielsen
  3. *
  4. *      This program is intended as a help to Amiga-users who has cats
  5. *    or other pets (or children) that messes with the Amiga as soon
  6. *    as you leave it for a second.
  7. *
  8. *      It installes an input-handler which lets you lock the keyboard
  9. *       and mouse by pressing a few buttons (currently LALT-CTRL-'l').
  10. *
  11. *      Once installed, the program only uses 190 bytes of memory. To
  12. *    remove the handler simply run the program again.
  13. *
  14. *    NOTE:    There's no need to 'RUN' or 'RUNBACK' this program from the
  15. *        CLI. It terminates immediately.
  16. *
  17. *HISTORY
  18. *          Made with Hisoft V2.12
  19. *
  20. *  V1.0   11-Apr-91: First attempt. Works of course
  21.                    
  22.     OPT O+
  23.     OPT O1+            ; Tells when a branch could be optimised to short
  24.     OPT i+            ; Tells when '#' is probably missing
  25.  
  26.         incdir        "AsmInc:"
  27.         include        "exec/exec_lib.i"
  28.         include        "exec/io.i"
  29.         include        "exec/memory.i"
  30.         include        "exec/interrupts.i"
  31.         include        "devices/input.i"
  32.         include        "devices/inputevent.i"
  33.         include        "libraries/dosextens.i"
  34.         include        "libraries/dos_lib.i"
  35.  
  36. Prepare        MACRO
  37.         IFC        '\1','Exec_Call'
  38.         movea.l        4.W,A6
  39.         ENDC
  40.         IFC        '\1','Intuition_Call'
  41.         movea.l        IntBase(DB),A6
  42.         ENDC
  43.         IFC        '\1','Gfx_Call'
  44.         movea.l        GfxBase(DB),A6
  45.         ENDC
  46.         IFC        '\1','Dos_Call'
  47.         movea.l        DosBase(DB),A6
  48.         ENDC
  49.         ENDM
  50. CallLib        MACRO
  51.         jsr        _LVO\1(A6)
  52.         ENDM
  53. Call        MACRO
  54.         bsr        \1
  55.         ENDM
  56. CallS        MACRO
  57.         bsr.S        \1
  58.         ENDM
  59. Push        MACRO
  60.         movem.l        \1,-(SP)
  61.         ENDM
  62. Pop        MACRO
  63.         movem.l        (SP)+,\1
  64.         ENDM
  65. rAPtr        MACRO        name
  66. DefSiz        set        DefSiz+4
  67. DefPtr        set        DefPtr-4
  68. \1        =        DefPtr
  69.         ENDM
  70. rLong        MACRO        name
  71. DefSiz        set        DefSiz+4
  72. DefPtr        set        DefPtr-4
  73. \1        =        DefPtr
  74.         ENDM
  75. rWord        MACRO        name
  76. DefSiz        set        DefSiz+2
  77. DefPtr        set        DefPtr-2
  78. \1        =        DefPtr
  79.         ENDM
  80. rByte        MACRO        name
  81. DefSiz        set        DefSiz+1
  82. DefPtr        set        DefPtr-1
  83. \1        =        DefPtr
  84.         ENDM
  85. rStorage    MACRO        name,size    ; Define storage
  86. DefSiz        set        DefSiz+\2
  87. DefPtr        set        DefPtr-\2
  88. \1        =        DefPtr
  89.         ENDM
  90. rEVEN        MACRO                ; Word boundary
  91.         IFNE        DefPtr&1
  92. DefPtr        set        DefPtr-1
  93. DefSiz        set        DefSiz+1
  94.         ENDC
  95.         ENDM
  96. rStart        MACRO                ; Define var section
  97. DefPtr        set        0
  98. DefSiz        set        0
  99.         ENDM
  100. rEnd        MACRO                ; End var section
  101. RelSize        =        DefSiz
  102.         ENDM
  103. rAlloc        MACRO                ; Allocate vars
  104.         link        DB,#-RelSize
  105.         ENDM
  106. rFree        MACRO                ; Deallocate vars
  107.         unlk        DB
  108.         ENDM
  109. rClear        MACRO                ; Reset all vars
  110.         movem.l        D0/DB,-(SP)
  111.         move.w        #RelSize-1,D0
  112. rClr.\@        clr.b        -(DB)
  113.         dbf        D0,rClr.\@
  114.         movem.l        (SP)+,D0/DB
  115.         ENDM
  116.  
  117. DB        EQUR        A4
  118.  
  119.         SECTION        InputLock,CODE
  120. InitProcess    rAlloc                    ; Allocate memory for variables
  121.         rClear                    ; Clear the memory
  122.         Prepare        Exec_Call
  123.         suba.l        A1,A1
  124.         CallLib        FindTask        ; Find us
  125.         move.l        D0,PProcess(DB)
  126.         movea.l        D0,A2
  127.         tst.l        pr_CLI(A2)
  128.         bne.S        GetLibs
  129. WBStart        lea        pr_MsgPort(A2),A0
  130.         CallLib        WaitPort        ; wait for a message
  131.         lea        pr_MsgPort(A2),A0
  132.         CallLib        GetMsg            ; then get it
  133.         move.l        D0,WBMsg(DB)        ; save it for later reply
  134. GetLibs        lea        DosName(PC),A1
  135.         CallLib        OldOpenLibrary
  136.         move.l        D0,DosBase(DB)
  137.         beq.S        Error
  138.  
  139.         CallLib        Forbid
  140.         lea        IHS(PC),A1
  141.         lea        ihs_PortName(A1),A1
  142.         CallLib        FindPort
  143.         move.l        D0,D2
  144.         CallLib        Permit
  145.         move.l        D2,D0            ; Does Forbid/Permit destroy scratch-registers ?
  146.         beq.S        DoInstall
  147. DoRemove    moveq        #REMOVED,D7
  148.         lea        IHS(PC),A0
  149.         lea        PSEndIHS1(PC),A1
  150.         lea        PSEndIHS2(PC),A2
  151.         Call        RemoveHandler
  152.         beq.S        ShowMsg
  153.         moveq        #CANTREMOVE,D7
  154.         bra.S        ShowMsg
  155. DoInstall    moveq        #INSTALLED,D7
  156.         lea        IHS(PC),A0
  157.         lea        PSPrepIHS1(PC),A1
  158.         lea        PSPrepIHS2(PC),A2
  159.         Call        InstallHandler
  160.         beq.S        ShowMsg
  161.         moveq        #CANTINSTALL,D7
  162. ShowMsg        move.l        D7,D0
  163.         Call        CONMsg
  164.  
  165. Error
  166. Exit        Prepare        Exec_Call
  167. FreeDos        move.l        DosBase(DB),D0
  168.         beq.S        ReplyWB
  169.         move.l        D0,A1
  170.         CallLib        CloseLibrary
  171. ReplyWB        move.l        WBMsg(DB),D2
  172.         beq.S        AllDone
  173.         CallLib        Forbid            ; We were started from WB
  174.         movea.l        D2,A1
  175.         CallLib        ReplyMsg        ; Reply WBMessage
  176. AllDone        rFree
  177.         moveq        #0,D0
  178.         rts
  179.  
  180. FHandle        EQUR        D5
  181. * Call: D0 = Msg-number
  182. CONMsg        Push        D0-D7/A0-A6
  183.         Prepare        Dos_Call
  184.         move.l        D0,D4
  185.         moveq        #0,D6
  186.         CallLib        Output
  187.         move.l        D0,FHandle
  188.         bne.S        1$
  189.         moveq        #1,D6
  190.         lea        CONName(PC),A0
  191.         move.l        A0,D1
  192.         move.l        #MODE_OLDFILE,D2
  193.         CallLib        Open
  194.         move.l        D0,FHandle
  195.         beq.S        2$
  196. 1$        moveq        #INFOMSG,D0
  197.         Call        SendMsg
  198.         move.l        D4,D0
  199.         Call        SendMsg
  200.         tst.l        D6
  201.         beq.S        2$
  202.         moveq        #127,D1
  203.         CallLib        Delay
  204.         move.l        FHandle,D1
  205.         CallLib        Close
  206. 2$        Pop        D0-D7/A0-A6
  207.         rts
  208.  
  209. * Call: D0 = Msg-number
  210. SendMsg        neg.l        D0
  211.         lsl.l        #1,D0
  212.         lea        MsgTable(PC),A0
  213.         add.w        0(A0,D0),A0
  214.         move.l        A0,D2
  215.         moveq        #-1,D3
  216. 1$        addq.l        #1,D3
  217.         tst.b        (A0)+
  218.         bne.S        1$
  219.         move.l        FHandle,D1
  220.         Prepare        Dos_Call
  221.         CallLib        Write
  222.         rts
  223.  
  224. INFOMSG        =0
  225. INSTALLED    =-1
  226. REMOVED        =-2
  227. CANTINSTALL    =-3
  228. CANTREMOVE    =-4
  229.  
  230. MsgText        MACRO
  231.         dc.w        \1-MsgTable
  232.         ENDM
  233. MsgTable    MsgText        Msg
  234.         MsgText        Msg1
  235.         MsgText        Msg2
  236.         MsgText        Msg3
  237.         MsgText        Msg4
  238.  
  239. CONName        dc.b        'CON:100/60/330/63/InputLock',0
  240. Msg        dc.b        10,$9B,'0;33m InputLock V1.0',10
  241.         dc.b        $9B,'0;31m 1991 by ',$9B,'0;33mPreben Nielsen',$9B,'0;31m',10,' ',0
  242. Msg1        dc.b        'has just been installed...',10,0
  243. Msg2        dc.b        'has just been removed...',10,0
  244. Msg3        dc.b        'Error: Cannot install handler',10,0
  245. Msg4        dc.b        'Error: Cannot remove handler',10,0
  246.         EVEN
  247.  
  248. rtsValue    EQUR        D7
  249. * This is general-purpose inputhandler removal-routine
  250. * It only needs an ihs with a port-name to remove the handler
  251. * Call:   A0 = ihs
  252. *      A1 = first ihs-installation-routine or NULL
  253. *      A2 = second ihs-installation-routine or NULL
  254. * Return: D0 = 0 means succes
  255. RemoveHandler    Push        D1/rtsValue/A0-A3/A6
  256.         moveq        #-1,rtsValue
  257.         move.l        A2,A3
  258.         move.l        A0,A2
  259.         move.l        A1,D1
  260.         beq.S        1$
  261.         jsr        (A1)        ; A0 = ihs
  262.         beq.S        2$
  263.         move.l        D0,A2
  264. 1$        move.l        A2,A0
  265.         Prepare        Exec_Call
  266.         moveq        #IND_REMHANDLER,D0
  267.         Call        TellInputDevice
  268.         move.l        D0,rtsValue
  269.         bne.S        2$
  270.         lea        ihs_Port(A2),A1
  271.         CallLib        RemPort
  272.         moveq        #0,D0
  273.         bra.S        3$
  274. 2$        moveq        #-1,D0
  275. 3$        move.l        A3,D1
  276.         beq.S        4$
  277.         move.l        A2,A0
  278.         jsr        (A3)        ; A0 = ihs, D0 = 0 means succes
  279. 4$        move.l        rtsValue,D0
  280.         Pop        D1/rtsValue/A0-A3/A6
  281.         rts
  282.  
  283. * This is general-purpose inputhandler installation-routine
  284. * It only needs an ihs with a port-name to install the handler
  285. * Call:   A0 = ihs
  286. *      A1 = first ihs-installation-routine or NULL
  287. *      A2 = second ihs-installation-routine or NULL
  288. * Return: D0 = 0 means succes
  289. InstallHandler    Push        D1/rtsValue/A0-A3/A6
  290.         moveq        #-1,rtsValue
  291.         move.l        A2,A3
  292.         move.l        A0,A2
  293.         move.l        A1,D1
  294.         beq.S        1$
  295.         jsr        (A1)        ; A0 = ihs
  296.         beq.S        2$
  297.         move.l        D0,A2
  298. 1$        move.l        A2,A0
  299.         moveq        #IND_ADDHANDLER,D0
  300.         Call        TellInputDevice
  301.         move.l        D0,rtsValue
  302.         bne.S        2$
  303.         lea        ihs_Port(A2),A1
  304.         lea        ihs_PortName(A2),A0
  305.         move.l        A0,MP+LN_NAME(A1)        ;MsgPort->mp_Node.ln_Name=Name;
  306.         clr.b        MP+LN_PRI(A1)            ;MsgPort->mp_Node.ln_Pri =0;
  307.         move.b        #NT_MSGPORT,MP+LN_TYPE(A1)    ;MsgPort->mp_Node.ln_Type=NT_MSGPORT;
  308.         move.b        #PA_IGNORE,MP_FLAGS(A1)        ;MsgPort->mp_Flags     =PA_IGNORE;
  309.         Prepare        Exec_Call
  310.         CallLib        AddPort
  311.         moveq        #0,D0
  312.         bra.S        3$
  313. 2$        moveq        #-1,D0
  314. 3$        move.l        A3,D1
  315.         beq.S        4$
  316.         move.l        A2,A0
  317.         jsr        (A3)        ; A0 = ihs, D0 = 0 means succes
  318. 4$        move.l        rtsValue,D0
  319.         Pop        D1/rtsValue/A0-A3/A6
  320.         rts
  321.  
  322. * Open the input device. Set up the I/O block to add or remove the
  323. * input handler, and send the request to the input device. Finally,
  324. * close the device
  325. * Call:   A0 = ihs
  326. *      D0 = Function to perform (IND_ADDHANDLER/IND_REMHANDLER)
  327. * Return: D0 = 0 means succes
  328. TellInputDevice    Push        D1-D2/rtsValue/A0-A3/A6
  329.         Prepare        Exec_Call
  330.         moveq        #-1,rtsValue
  331.         move.l        D0,D2
  332.         move.l        A0,A2
  333.         lea        IReq(DB),A0
  334.         moveq        #IOSTD_SIZE,D0
  335.         Call        MemClear
  336.         lea        IPort(DB),A0
  337.         moveq        #MP_SIZE,D0
  338.         Call        MemClear
  339.         move.l        A0,A3
  340.         move.b        #NT_MSGPORT,MP+LN_TYPE(A3)    ; mp_Node.ln_Type=NT_MSGPORT;
  341.         move.b        #PA_SIGNAL,MP_FLAGS(A3)        ; mp_Flags    =PA_SIGNAL;
  342.         moveq        #-1,D0
  343.         CallLib        AllocSignal
  344.         move.b        D0,MP_SIGBIT(A3)        ; mp_SigBit    =MPSigBit;
  345.         bmi.S        2$
  346.         suba.l        A1,A1
  347.         CallLib        FindTask
  348.         move.l        D0,MP_SIGTASK(A3)        ; mp_SigTask     =FindTask(0);
  349.         lea        IReq(DB),A1
  350.         move.l        A3,IO+MN_REPLYPORT(A1)        ; ExtReq->io_Message.mn_ReplyPort   =taskReplyPort;
  351.         move.b        #NT_MESSAGE,IO+MN+LN_TYPE(A1)    ; ExtReq->io_Message.mn_Node.ln_Type=NT_MESSAGE;
  352.         lea        InputName(PC),A0        ; input.device
  353.         moveq        #0,D0                ; unit#
  354.         moveq        #0,D1                ; flags
  355.         CallLib        OpenDevice
  356.         tst.w        D0                ; flag: error if > 0
  357.         bne.S        1$
  358.         lea        IReq(DB),A1
  359.         move.w        D2,IO_COMMAND(A1)
  360.         lea        ihs_Interrupt(A2),A0
  361.         move.l        A0,IO_DATA(A1)
  362.         CallLib        DoIO
  363.         move.l        D0,rtsValue
  364.         lea        IReq(DB),A1
  365.         CallLib        CloseDevice
  366. 1$        move.b        MP_SIGBIT(A3),D0
  367.         CallLib        FreeSignal
  368. 2$        move.l        rtsValue,D0
  369.         Pop        D1-D2/rtsValue/A0-A3/A6
  370.         rts
  371.  
  372. * Call: A0    = Memory area
  373. *    D0:16 = Count
  374. MemClear    Push        D0-D1/A0
  375.         moveq        #0,D1
  376.         bra.S        2$
  377. 1$        move.b        D1,(A0)+
  378. 2$        dbf        D0,1$
  379.         Pop        D0-D1/A0
  380.         rts
  381.  
  382. * Call: A0   = Source
  383. *    A1   = Destination
  384. *    D0:16= Count
  385. MemCopy        Push        D0/A0-A1
  386.         bra.S        2$
  387. 1$        move.b        (A0)+,(A1)+
  388. 2$        dbf        D0,1$
  389.         Pop        D0/A0-A1
  390.         rts
  391.  
  392. * Each handler should have such a pair of installation-routine
  393. * The first one is passed to InstallHandler in A1 and it
  394. * is called immediately when entering InstallHandler
  395. * The second one is passed to InstallHandler in A2 and it
  396. * is called after attempt to install handler and message-port
  397. * -----------------------------------------------------------------
  398. * Call:   A0 = ihs
  399. * Return: D0 has to point to ihs to be used when installation proceeds
  400. *      If D0 = 0 then installation is aborted
  401. PSPrepIHS1    Push        D1/A0-A1/A6
  402.         Prepare        Exec_Call
  403.         move.l        #HandlerSize,D0
  404.         move.l        #MEMF_PUBLIC|MEMF_CLEAR,D1
  405.         CallLib        AllocMem
  406.         move.l        D0,HMem(DB)
  407.         beq.S        2$
  408.         move.l        D0,A1
  409.         lea        IHS(PC),A0
  410.         move.l        #HandlerSize,D0
  411.         Call        MemCopy
  412.         move.l        D0,ihs_Length(A1)        ; This will enable removal by other programs
  413.         lea        HandlerCode-IHS(A1),A0
  414.         move.l        A0,ihs_Interrupt+IS_CODE(A1)    ; HandlerBlock.HInterrupt.is_Code = Handler
  415.         clr.l        ihs_Interrupt+IS_DATA(A1)    ; HandlerBlock.HInterrupt.is_Data = 0
  416.         move.b        #HPRI,ihs_Interrupt+LN_PRI(A1)    ; HandlerBlock.HInterrupt.is_Node.ln_Pri = PRI
  417.         move.l        A1,D0
  418. 2$        Pop        D1/A0-A1/A6
  419.         rts
  420.  
  421. * Call:   A0 = ihs
  422. *         D0 = 0 means everything went perfect
  423. *             -1 means something went wrong during installation
  424. PSPrepIHS2    Push        D0-D1/A0-A1/A6
  425.         tst.l        D0
  426.         beq.S        1$
  427.         move.l        HMem(DB),D0
  428.         beq.S        1$
  429.         move.l        D0,A1
  430.         move.l        #HandlerSize,D0
  431.         Prepare        Exec_Call
  432.         CallLib        FreeMem
  433. 1$        Pop        D0-D1/A0-A1/A6
  434.         rts
  435.  
  436. * Each handler should have such a pair of ending-routine
  437. * The first one is passed to RemoveHandler in A1 and it
  438. * is called immediately when entering RemoveHandler
  439. * The second one is passed to RemoveHandler in A2 and it
  440. * is called after attempt to remove handler and message-port
  441. * -----------------------------------------------------------------
  442. * Call:   A0 = ihs
  443. * Return: D0 has to point to ihs to be used when removal proceeds
  444. *      If D0 = 0 then removal is aborted
  445. PSEndIHS1    Push        D1-D2/A0-A1/A6
  446.         Prepare        Exec_Call
  447.         CallLib        Forbid
  448.         lea        ihs_PortName(A0),A1
  449.         CallLib        FindPort
  450.         move.l        D0,D2
  451.         CallLib        Permit
  452.         move.l        D2,D0            ; Does Forbid/Permit destroy scratch-registers ?
  453.         Pop        D1-D2/A0-A1/A6
  454.         rts
  455. * Call:   A0 = ihs
  456. *         D0 = 0 means everything went perfect
  457. *             -1 means something went wrong during removal
  458. PSEndIHS2    Push        D0-D1/A0-A1/A6
  459.         tst.l        D0
  460.         bmi.S        1$
  461.         Prepare        Exec_Call
  462.         move.l        ihs_Length(A0),D0
  463.         move.l        A0,A1
  464.         CallLib        FreeMem
  465. 1$        Pop        D0-D1/A0-A1/A6
  466.         rts
  467.  
  468.  
  469. *====================== Input-handler start =========================
  470. ihs_Port    =0
  471. ihs_Interrupt    =MP_SIZE
  472. ihs_ID        =MP_SIZE+IS_SIZE
  473. ihs_Length    =MP_SIZE+IS_SIZE+4
  474. ihs_Flags    =MP_SIZE+IS_SIZE+8
  475. ihs_PortName    =MP_SIZE+IS_SIZE+10
  476.  
  477. ihs_Start    MACRO
  478.         dcb.b        MP_SIZE        ; Message-Port structure
  479.         dcb.b        IS_SIZE        ; Interrupt structure
  480.         dc.l        'P_IH'        ; ID (Handler made by me)
  481.         dc.l        0        ; Length of handler 
  482.         dc.w        0        ; Flags
  483.         dc.b        \1,0
  484.         EVEN
  485.         ENDM
  486.  
  487. HPRI        =127                ; Handler-priority
  488. HDisabled    =0
  489. HNoExtRemoval    =1                ; Future
  490.  
  491. * This is the handler-block
  492. IHS        ihs_Start    <'InputLock V1.0 Port'>
  493. * Local variables
  494. Chain        dc.l        0
  495. Status        dc.w        0
  496. INPUTDISABLED    =0
  497. * For each event in the event list:
  498. *  If we were waiting for this event then process it.
  499. * When all the events have been checked, return the event list so that
  500. * others can do their things.
  501. PEvent        EQUR    A2                ; Previous Event
  502. Event        EQUR    A1                ; This Event
  503. Bits        EQUR    A0
  504.  
  505. Next        =ie_NextEvent
  506. Class        =ie_Class
  507. Code        =ie_Code
  508. Qual        =ie_Qualifier
  509. * These are the qualifier-keys the input-handler waits for
  510. QUALIFIERS    =IEQUALIFIER_LALT|IEQUALIFIER_CONTROL
  511. * These are the keys the input-handler acts on
  512. Toggle_Key    =$28                    ; 'l'
  513. * Call:  A0 = List of InputEvents, A1 = HandlerData
  514. HandlerCode    Push        Bits/Event/PEvent
  515.         move.w        IHS+ihs_Flags(PC),D0
  516.         btst        #HDisabled,D0        ; Future feature
  517.         bne.S        NoMoreEvents
  518.         lea        Chain(PC),PEvent
  519.         move.l        A0,Next(PEvent)
  520.         lea        Status(PC),Bits
  521. ieLoop        move.l        Next(PEvent),Event
  522.         move.l        Event,D0
  523.         beq.S        NoMoreEvents
  524.         cmpi.b        #IECLASS_RAWMOUSE,Class(Event)
  525.         beq.S        CheckLock
  526.         cmpi.b        #IECLASS_RAWKEY,Class(Event)
  527.         bne.S        DontRemove
  528.         move.w        Qual(Event),D0
  529.         andi.w        #QUALIFIERS|IEQUALIFIER_REPEAT,D0
  530.         cmpi.w        #QUALIFIERS,D0
  531.         bne.S        CheckLock
  532.         cmp.w        #Toggle_Key,Code(Event)
  533.         bne.S        CheckLock
  534.         bchg        #INPUTDISABLED,(Bits)
  535.         bra.S        Remove
  536. CheckLock    btst        #INPUTDISABLED,(Bits)
  537.         bne.S        Remove
  538. * Just move on to next Event
  539. DontRemove    move.l        Event,PEvent
  540.         bra.S        ieLoop
  541. * Remove event from chain and move on to next Event
  542. Remove        move.l        Next(Event),Next(PEvent)
  543.         bra.S        ieLoop
  544. * Lets return
  545. NoMoreEvents    Pop        Bits/Event/PEvent
  546.         move.l        Chain(PC),D0        ; Return (shortened ?) chain
  547.         rts
  548. HandlerSize    =        *-IHS
  549. *====================== Input-handler end ===========================
  550.  
  551. *====================== Data-definition start =======================
  552.  rStart
  553.  rAPtr        PProcess
  554.  rAPtr        WBMsg
  555.  rAPtr        DosBase
  556.  rStorage    IReq,IOSTD_SIZE
  557.  rStorage    IPort,MP_SIZE
  558.  rAPtr        HMem
  559.  rEnd
  560.  
  561. DosName        dc.b        'dos.library',0
  562. InputName    dc.b        'input.device',0
  563.         END
  564.  
  565. * These defines are here for quick reference only
  566.  --- InputEvent.ie_Class ---
  567. IECLASS_NULL        0x00    A NOP input event
  568. IECLASS_RAWKEY        0x01    A raw keycode from the keyboard device
  569. IECLASS_RAWMOUSE    0x02    The raw mouse report from the game port device
  570. IECLASS_EVENT        0x03    A private console event
  571. IECLASS_POINTERPOS    0x04    A Pointer Position report
  572. IECLASS_TIMER        0x06    A timer event
  573. IECLASS_GADGETDOWN    0x07    select button pressed down over a Gadget (address in ie_EventAddress)
  574. IECLASS_GADGETUP    0x08    select button released over the same Gadget (address in ie_EventAddress)
  575. IECLASS_REQUESTER    0x09    some Requester activity has taken place.  See Codes REQCLEAR and REQSET
  576. IECLASS_MENULIST    0x0A    this is a Menu Number transmission (Menu number is in ie_Code)
  577. IECLASS_CLOSEWINDOW    0x0B    User has selected the active Window's Close Gadget
  578. IECLASS_SIZEWINDOW    0x0C    this Window has a new size
  579. IECLASS_REFRESHWINDOW    0x0D    the Window pointed to by ie_EventAddress needs to be refreshed
  580. IECLASS_NEWPREFS    0x0E    new preferences are available
  581. IECLASS_DISKREMOVED    0x0F    the disk has been removed
  582. IECLASS_DISKINSERTED    0x10    the disk has been inserted
  583. IECLASS_ACTIVEWINDOW    0x11    the window is about to be made active
  584. IECLASS_INACTIVEWINDOW    0x12    the window is about to be made inactive
  585. IECLASS_MAX        0x12    the last class
  586.  
  587.   --- InputEvent.ie_Code ---
  588. IECLASS_RAWKEY
  589. IECODE_UP_PREFIX    0x80
  590. IECODE_KEY_CODE_FIRST    0x00
  591. IECODE_KEY_CODE_LAST    0x77
  592. IECODE_COMM_CODE_FIRST    0x78
  593. IECODE_COMM_CODE_LAST    0x7F
  594.   
  595. IECLASS_ANSI
  596. IECODE_C0_FIRST        0x00
  597. IECODE_C0_LAST        0x1F
  598. IECODE_ASCII_FIRST    0x20
  599. IECODE_ASCII_LAST    0x7E
  600. IECODE_ASCII_DEL    0x7F
  601. IECODE_C1_FIRST        0x80
  602. IECODE_C1_LAST        0x9F
  603. IECODE_LATIN1_FIRST    0xA0
  604. IECODE_LATIN1_LAST    0xFF
  605.   
  606. IECLASS_RAWMOUSE
  607. IECODE_LBUTTON        0x68    also uses IECODE_UP_PREFIX
  608. IECODE_RBUTTON        0x69
  609. IECODE_MBUTTON        0x6A
  610. IECODE_NOBUTTON        0xFF
  611.   
  612. IECLASS_EVENT
  613. IECODE_NEWACTIVE    0x01    active input window changed
  614.  
  615. IECLASS_REQUESTER Codes
  616. REQSET is broadcast when the first Requester (not subsequent ones) opens
  617. in the Window
  618.  
  619. IECODE_REQSET        0x01
  620. REQCLEAR is broadcast when the last Requester clears out of the Window
  621. IECODE_REQCLEAR        0x00
  622.  
  623.  --- InputEvent.ie_Qualifier ---
  624. IEQUALIFIER_LSHIFT        0x0001
  625. IEQUALIFIER_RSHIFT        0x0002
  626. IEQUALIFIER_CAPSLOCK        0x0004
  627. IEQUALIFIER_CONTROL        0x0008
  628. IEQUALIFIER_LALT        0x0010
  629. IEQUALIFIER_RALT        0x0020
  630. IEQUALIFIER_LCOMMAND        0x0040
  631. IEQUALIFIER_RCOMMAND        0x0080
  632. IEQUALIFIER_NUMERICPAD        0x0100
  633. IEQUALIFIER_REPEAT        0x0200
  634. IEQUALIFIER_INTERRUPT        0x0400
  635. IEQUALIFIER_MULTIBROADCAST    0x0800
  636. IEQUALIFIER_MIDBUTTON        0x1000
  637. IEQUALIFIER_RBUTTON        0x2000
  638. IEQUALIFIER_LEFTBUTTON        0x4000
  639. IEQUALIFIER_RELATIVEMOUSE    0x8000
  640.  
  641. IEQUALIFIERB_LSHIFT        0
  642. IEQUALIFIERB_RSHIFT        1
  643. IEQUALIFIERB_CAPSLOCK        2
  644. IEQUALIFIERB_CONTROL        3
  645. IEQUALIFIERB_LALT        4
  646. IEQUALIFIERB_RALT        5
  647. IEQUALIFIERB_LCOMMAND        6
  648. IEQUALIFIERB_RCOMMAND        7
  649. IEQUALIFIERB_NUMERICPAD        8
  650. IEQUALIFIERB_REPEAT        9
  651. IEQUALIFIERB_INTERRUPT        10
  652. IEQUALIFIERB_MULTIBROADCAST    11
  653. IEQUALIFIERB_MIDBUTTON        12
  654. IEQUALIFIERB_RBUTTON        13
  655. IEQUALIFIERB_LEFTBUTTON        14
  656. IEQUALIFIERB_RELATIVEMOUSE    15
  657.   
  658. struct InputEvent
  659. {
  660.  struct  InputEvent *ie_NextEvent    ;the chronologically next event
  661.  UBYTE   ie_Class            ;the input event class
  662.  UBYTE   ie_SubClass            ;optional subclass of the class
  663.  UWORD   ie_Code            ;the input event code
  664.  UWORD   ie_Qualifier            ;qualifiers in effect for the event
  665.  union
  666.   {
  667.    struct
  668.     {
  669.      WORD    ie_x            ;the pointer position for the event
  670.      WORD    ie_y
  671.     } ie_xy
  672.    APTR    ie_addr
  673.   } ie_position
  674.   struct timeval ie_TimeStamp        ;the system tick at the event
  675. };
  676.  
  677. ie_X            =ie_position.ie_xy.ie_x
  678. ie_Y            =ie_position.ie_xy.ie_y
  679. ie_EventAddress        =ie_position.ie_addr
  680.  
  681.